﻿using System;
using System.Collections;
using System.Text;
using System.IO;

namespace Layers
{
    public class MyLogger
    {
        public NLog.Logger nLog;
        public TextWriter Writer{get{return DefaultWriter;}}
        public static TextWriter DefaultWriter = new DupTextWriter(Console.Out, LogStream);

        public static StreamWriter LogStream { get {
            StreamWriter w = new StreamWriter("Layers.log");
            w.AutoFlush = true;
            return w;
        } }
        public static MyLogger Default { get { return new MyLogger(); } }

        public MyLogger()
        {
            nLog = NLog.LogManager.GetCurrentClassLogger();
        }

        public void Info(string msg, params object[] args)
        {
            if (null != nLog)
                nLog.Info(msg, args);
            if (null != Writer)
                Writer.WriteLine(msg, args);
        }

        public void Debug(string msg, params object[] args)
        {
            if (null != nLog)
                nLog.Debug(msg, args);
            if (null != Writer)
                Writer.WriteLine(msg, args);
        }

        public static void WriteLine(string msg, params object[] args)
        {
            if (null != DefaultWriter)
            {
                DefaultWriter.WriteLine(msg, args);
            }
        }
        
        public static void Write(string msg, params object[] args)
        {
            if (null != DefaultWriter)
            {
                DefaultWriter.Write(msg, args);
            }
        }
    }

}